RPi Hardware Interface
etada_netio_jni_HardwareIO.h File Reference
#include <jni.h>

Go to the source code of this file.

Functions

JNIEXPORT jbyteArray JNICALL Java_etada_netio_jni_HardwareIO_spi (JNIEnv *env, jobject inst, jint speed_Hz, jbyte mode, jbyte bits_per_word, jshort delay, jbyteArray master_out, jobject deviceHandleInst)
 
JNIEXPORT void JNICALL Java_etada_netio_jni_HardwareIO_bitmaskSequence (JNIEnv *env, jobject inst, jintArray bitmasks, jintArray durations, jint speed_Hz, jbyte mode, jbyte bits_per_word, jshort delay, jlong timeout_ms, jobject deviceHandleInst)
 
JNIEXPORT void JNICALL Java_etada_netio_jni_HardwareIO_bitmaskLargeDataSequence (JNIEnv *env, jobject inst, jintArray bitmasks, jintArray durations, jshortArray adcBuffer0, jshortArray adcBuffer1, jshortArray adcBuffer2, jshortArray adcBuffer3, jint speed_Hz, jbyte mode, jbyte bits_per_word, jshort delay, jlong timeout_ms, jobject deviceHandleInst)
 
JNIEXPORT jintArray JNICALL Java_etada_netio_jni_HardwareIO_dataRecordStream (JNIEnv *env, jobject inst, jintArray addresses_24bit, jint speed_Hz, jbyte mode, jbyte bits_per_word, jshort delay, jobject deviceHandleInst)
 
JNIEXPORT void JNICALL Java_etada_netio_jni_HardwareIO_writeI2CData (JNIEnv *env, jobject classInst, jbyte address, jbyteArray data, jobject deviceHandle)
 
JNIEXPORT jbyteArray JNICALL Java_etada_netio_jni_HardwareIO_readI2CData (JNIEnv *env, jobject classInst, jbyte address, jint dataSize, jobject deviceHandle)
 

Function Documentation

JNIEXPORT void JNICALL Java_etada_netio_jni_HardwareIO_bitmaskLargeDataSequence ( JNIEnv *  env,
jobject  inst,
jintArray  bitmasks,
jintArray  durations,
jshortArray  adcBuffer0,
jshortArray  adcBuffer1,
jshortArray  adcBuffer2,
jshortArray  adcBuffer3,
jint  speed_Hz,
jbyte  mode,
jbyte  bits_per_word,
jshort  delay,
jlong  timeout_ms,
jobject  deviceHandleInst 
)

Runs a protocol consisting of a whole stack (FIFO) of timed bitmasks, using low-level data structures and driver usage to allow for very short duration timed bitmasks to prevent the SPI communication lag from violating the timing requirements. Furthermore, this function reads from the ADC data buffers during the execution of the bitmask sequence so that more data can be collected than would fit inside the on-chip FPGA memory.
Returns when the sequence is complete.

Parameters
envThe JVM environment
instParent java object class instance
bitmasksArray of 32-bit digital output masks (1 for high, 0 for low).
durationsThe corresponding number of FPGA clock cycles to hold each bitmask
adcBuffer0data buffer to hold the expected total number of ADC records in channel 0
adcBuffer1data buffer to hold the expected total number of ADC records in channel 1
adcBuffer2data buffer to hold the expected total number of ADC records in channel 2
adcBuffer3data buffer to hold the expected total number of ADC records in channel 3
speed_HzThe frequency (in bits per second) to communicate with the FPGA. See etada.netio.jni.DeviceHandle.
modeThe SPI communication protocol type number. See etada.netio.jni.DeviceHandle.
bits_per_wordThe number of bits per byte. See etada.netio.jni.DeviceHandle.
delayThe delay between bytes in the SPI communication (none needed). See etada.netio.jni.DeviceHandle.
timeout_msNumber of milliseconds to wait for the bitmask sequence to run before aborting.
deviceHandleInstInstance of etada.netio.jni.DeviceHandle
Exceptions
java.io.IOExceptionThrown on JVM stack if there were any detectable problems or failures while communicating with the FPGA.
JNIEXPORT void JNICALL Java_etada_netio_jni_HardwareIO_bitmaskSequence ( JNIEnv *  env,
jobject  inst,
jintArray  bitmasks,
jintArray  durations,
jint  speed_Hz,
jbyte  mode,
jbyte  bits_per_word,
jshort  delay,
jlong  timeout_ms,
jobject  deviceHandleInst 
)

Runs a protocol consisting of a whole stack (FIFO) of timed bitmasks, using low-level data structures and driver usage to allow for very short duration timed bitmasks to prevent the SPI communication lag from violating the timing requirements. Returns when the sequence is complete.

Parameters
envThe JVM environment
instParent java object class instance
bitmasksArray of 32-bit digital output masks (1 for high, 0 for low).
durationsThe corresponding number of FPGA clock cycles to hold each bitmask
speed_HzThe frequency (in bits per second) to communicate with the FPGA. See etada.netio.jni.DeviceHandle.
modeThe SPI communication protocol type number. See etada.netio.jni.DeviceHandle.
bits_per_wordThe number of bits per byte. See etada.netio.jni.DeviceHandle.
delayThe delay between bytes in the SPI communication (none needed). See etada.netio.jni.DeviceHandle.
timeout_msNumber of milliseconds to wait for the bitmask sequence to run before aborting.
deviceHandleInstInstance of etada.netio.jni.DeviceHandle
Exceptions
java.io.IOExceptionThrown on JVM stack if there were any detectable problems or failures while communicating with the FPGA.
JNIEXPORT jintArray JNICALL Java_etada_netio_jni_HardwareIO_dataRecordStream ( JNIEnv *  env,
jobject  inst,
jintArray  addresses_24bit,
jint  speed_Hz,
jbyte  mode,
jbyte  bits_per_word,
jshort  delay,
jobject  deviceHandleInst 
)

Quickly reads the ADC data recorded in the FPGA's internal data record memory, returning an array of integers where each integer is the stored value at each corresponding address in the addresses array.

Parameters
envThe JVM environment
instParent java object class instance
addresses_24bitArray of memory addresses. An address is 3 bytes stored in a 4-byte integer, where the two least significant bytes are the record number and the third least significant byte is the ADC channel (e.g. 0x00020A21 refers to record number 0x0A21 for ADC channel 2)
speed_HzThe frequency (in bits per second) to communicate with the FPGA. See etada.netio.jni.DeviceHandle.
modeThe SPI communication protocol type number. See etada.netio.jni.DeviceHandle.
bits_per_wordThe number of bits per byte. See etada.netio.jni.DeviceHandle.
delayThe delay between bytes in the SPI communication (none needed). See etada.netio.jni.DeviceHandle.
deviceHandleInstInstance of etada.netio.jni.DeviceHandle
Returns
Array of 16 bit ADC values as raw integers (you will need to divide by bits-per-volt to calculate real value).
Exceptions
java.io.IOExceptionThrown on JVM stack if there were any detectable problems or failures while communicating with the FPGA.
JNIEXPORT jbyteArray JNICALL Java_etada_netio_jni_HardwareIO_readI2CData ( JNIEnv *  env,
jobject  classInst,
jbyte  address,
jint  dataSize,
jobject  deviceHandle 
)

Reads a series of bytes from the RPi's I2C pins.

Parameters
envThe JVM environment
instParent java object class instance
addressAddress to send the data to
dataByteCountNumber of bytes to read
devThe device driver descriptor
Returns
The bytes that were read from the I2C slave
Exceptions
java.io.IOExceptionThrown if there were any detectable problems or failures while using the I2C linux driver
JNIEXPORT jbyteArray JNICALL Java_etada_netio_jni_HardwareIO_spi ( JNIEnv *  env,
jobject  inst,
jint  speed_Hz,
jbyte  mode,
jbyte  bits_per_word,
jshort  delay,
jbyteArray  master_out,
jobject  deviceHandleInst 
)

Performs a single SPI communication with the FPGA and returns the bytes that were read over the course of the FPGA. The FPGA precesses the SPI data packet while it is still receiving it and thus is able to put the return data in the same SPI communication as the command. Commands are 16 bytes in length.

Parameters
envThe JVM environment
instParent java object class instance
speed_HzThe frequency (in bits per second) to communicate with the FPGA. See etada.netio.config.SPIInfo.
modeThe SPI communication protocol type number. See etada.netio.config.SPIInfo.
bits_per_wordThe number of bits per byte. See etada.netio.config.SPIInfo.
delayThe delay between bytes in the SPI communication (none needed). See etada.netio.config.SPIInfo.
master_outThe SPI data packet to send. Should be 16 bytes.
deviceHandleInstInstance of etada.netio.jni.DeviceHandle
Returns
Returns a byte array of the same size as master_out containing the byte-for-byte response from the FPGA to the communication.
Exceptions
java.io.IOExceptionThrown on JVM stack if there were any detectable problems or failures while communicating with the FPGA.
JNIEXPORT void JNICALL Java_etada_netio_jni_HardwareIO_writeI2CData ( JNIEnv *  env,
jobject  classInst,
jbyte  address,
jbyteArray  data,
jobject  deviceHandle 
)

Writes a series of bytes to the RPi's I2C pins.

Parameters
envThe JVM environment
instParent java object class instance
addressAddress to send the data to
dataThe bytes to send
devThe device driver descriptor
Exceptions
java.io.IOExceptionThrown if there were any detectable problems or failures while using the I2C linux driver